package com.cyc.basic.test.suanfa;

/**
 * @author: chenyunchang
 * @date 2023/8/25 18:16
 * @description:
 */
public class 移除元素 {
    public static void main(String[] args) {

    }

    public static int removeElement(int[] nums, int val) {
        int slow = 0;
        int n = nums.length;
        for(int fast = 0; fast < n; fast++) {
            if (nums[fast] != val){
                nums[slow] = nums[fast];
                slow++;
            }
        }
        return slow;
    }

}
